Back to course home
0% completed
Vote For New Content
LinkedIn Hard
Max Points on a Line (hard)
Solution: Max Points on a Line
Closest Binary Search Tree Value II (hard)
Solution: Closest Binary Search Tree Value II
Word Ladder (hard)
Solution: Word Ladder
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Largest Rectangle in Histogram (hard)
Solution: Largest Rectangle in Histogram
Serialize and Deserialize Binary Tree (hard)
Solution: Serialize and Deserialize Binary Tree
Maximum Product Subarray (medium)
Problem Statement
Given an integer array, find the contiguous subarray (at least one number in it) that has the maximum product. Return this maximum product.
Examples
-
- Input: [2,3,-2,4]
- Expected Output: 6
- Justification: The subarray [2,3] has the maximum product of 6.
-
- Input: [-2,0,-1]
- Expected Output: 0
- Justification: The subarray [0] has the maximum product of 0.
-
- Input: [-2,3,2,-4]
- Expected Output: 48
- Justification: The subarray [-2,3,2,-4] has the maximum product of 48.
Constraints:
- 1 <= nums.length <= 2*104
-10 <= nums[i] <= 10- The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Kth Smallest Number
Solution: Maximum Product Subarray
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself